package mwt.xml.xdbforms.dbms.metadata.impl;

/**
 * Retrieves a description of the foreign key columns that reference
 * the given table's primary key columns (the foreign keys exported by a table).
 *
 * Retrieves a description of the primary key columns that are referenced
 * by the given table's foreign key columns (the primary keys imported by a table)
 */
public class ForeignKeyMetadata {

    /** primary key table name being imported  */
    private String pkTableName;

    /** primary key column name being imported */
    private String pkColumnName;

    /** foreign key table name */
    private String fkTableName;

    /** foreign key column name  */
    private String fkColumnName;

    /** 
     * sequence number within a foreign key( a value of 1 represents 
     * the first column of the foreign key, a value of 2 would represent 
     * the second column within the foreign key) 
     */
    private short seq;

    /**
     * What happens to a foreign key when the primary key is updated:
     * importedNoAction - do not allow update of primary key if it has been imported
     * importedKeyCascade - change imported key to agree with primary key update
     * importedKeySetNull - change imported key to NULL if its primary key has been updated
     * importedKeySetDefault - change imported key to default values if its primary key has been updated
     * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
     */
    private short updateRule;

    /**
     * What happens to the foreign key when primary is deleted.
     * importedKeyNoAction - do not allow delete of primary key if it has been imported
     * importedKeyCascade - delete rows that import a deleted key
     * importedKeySetNull - change imported key to NULL if its primary key has been deleted
     * importedKeyRestrict - same as importedKeyNoAction (for ODBC 2.x compatibility)
     * importedKeySetDefault - change imported key to default if its primary key has been deleted
     */
    private short deleteRule;

    /** foreign key name (may be null) */
    private String fkName;

    /** primary key name (may be null) */
    private String pkName;

    public ForeignKeyMetadata() {
        super();
    }

    public ForeignKeyMetadata(String pkTableName, String pkColumnName,
                              String fkTableName, String fkColumnName, short seq,
                              short updateRule, short deleteRule, String fkName,
                              String pkName) {
        this.pkTableName = pkTableName;
        this.pkColumnName = pkColumnName;
        this.fkTableName = fkTableName;
        this.fkColumnName = fkColumnName;
        this.seq = seq;
        this.updateRule = updateRule;
        this.deleteRule = deleteRule;
        this.fkName = fkName;
        this.pkName = pkName;
    }


    public short getDeleteRule() {
        return deleteRule;
    }

    public void setDeleteRule(short deleteRule) {
        this.deleteRule = deleteRule;
    }

    public String getFkColumnName() {
        return fkColumnName;
    }

    public void setFkColumnName(String fkColumnName) {
        this.fkColumnName = fkColumnName;
    }

    public String getFkName() {
        return fkName;
    }

    public void setFkName(String fkName) {
        this.fkName = fkName;
    }

    public String getFkTableName() {
        return fkTableName;
    }

    public void setFkTableName(String fkTableName) {
        this.fkTableName = fkTableName;
    }

    public String getPkColumnName() {
        return pkColumnName;
    }

    public void setPkColumnName(String pkColumnName) {
        this.pkColumnName = pkColumnName;
    }

    public String getPkName() {
        return pkName;
    }

    public void setPkName(String pkName) {
        this.pkName = pkName;
    }

    public String getPkTableName() {
        return pkTableName;
    }

    public void setPkTableName(String pkTableName) {
        this.pkTableName = pkTableName;
    }

    public short getSeq() {
        return seq;
    }

    public void setSeq(short seq) {
        this.seq = seq;
    }

    public short getUpdateRule() {
        return updateRule;
    }

    public void setUpdateRule(short updateRule) {
        this.updateRule = updateRule;
    }
}
